<?php
/**
 * [YIZHIKEJI System] Copyright (c) 2014 YIZHIKEJI.Com
 * YIZHIKEJI is NOT a free software, it under the license terms, visited http://www.yz929.cn/ for more details.
 */
defined('IN_IA') or exit('Access Denied');
load()->model('app');
$dos = array('display', 'login_out');
$do = in_array($do, $dos) ? $do : 'display';
load()->func('tpl');

if($do == 'login_out') {
	unset($_SESSION);
	session_destroy();
	isetcookie('logout', 1, 60);
	$logoutjs = "<script language=\"javascript\" type=\"text/javascript\">window.location.href=\"" . url('auth/login/') . "\";</script>";
	exit($logoutjs);
}

if ($do == 'display') {
	$navs = app_navs('profile');
	$modules = uni_modules();
	$groups = $others = array();
	if(!empty($navs)) {
		foreach($navs as $row) {
			if(!empty($row['module'])) {
				$groups[$row['module']][] = $row;
			} else {
				$others[] = $row;
			}
		}
	}
	
	$profile = mc_fetch($_W['uid'], array('nickname', 'avatar', 'mobile', 'groupid'));
//	$mcgroups = mc_groups();
//	$profile['group'] = $mcgroups[$profile['groupid']];
//	if(isset($setting['uc']['status']) && $setting['uc']['status'] == '1') {
//		$uc = $setting['uc'];
//		$sql = 'SELECT * FROM ' . tablename('mc_mapping_ucenter') . ' WHERE `uniacid`=:uniacid AND `uid`=:uid';
//		$pars = array();
//		$pars[':uniacid'] = $_W['uniacid'];
//		$pars[':uid'] = $_W['member']['uid'];
//		$mapping = pdo_fetch($sql, $pars);
//		if(empty($mapping)) {
//		} else {
//			mc_init_uc();
//			$u = uc_get_user($mapping['centeruid'], true);
//			$ucUser = array(
//				'uid' => $u[0],
//				'username' => $u[1],
//				'email' => $u[2]
//			);
//		}
//	}
//	if (empty($setting['passport']['focusreg'])) {
//		$reregister = false;
//		if ($_W['member']['email'] == md5($_W['openid']).'@yz929.cn') {
//			$reregister = true;
//		}
//	}
    //是否为商家
    $_W['isseller'] = false;
    if(pdo_get('users',array('openid'=>$_W['openid']))){
        $_W['isseller'] = true;
    }
}

template('mc/home');